package com.kefu.boss.vo;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.kefu.boss.model.BossVersion;
import com.kefu.common.context.KefuContext;
import com.kefu.common.vo.AbstractUpdateVo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.stream.Collectors;

@Data
@ApiModel("版本编辑")
public class BossVersionUpdateVo extends AbstractUpdateVo<BossVersion, String> {
    /**
     * 主键
     */
    @NotEmpty
    @ApiModelProperty(value = "主键")
    private String id;

    /**
     * 版本名称
     */
    @ApiModelProperty(value = "版本名称")
    private String versionName;
    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    private String remark;

    /**
     * 版本菜单
     */
    @ApiModelProperty(name = "menuList", value = "版本菜单")
    private List<String> menuList;
    
    @Override
    public BossVersion convert() {
        BossVersion info = BeanUtil.toBean(this, BossVersion.class);
        if (CollUtil.isNotEmpty(menuList)) {
            info.setVersionMenus(menuList.stream().collect(Collectors.joining(",")));
        }
        info.setRemark(remark);
        info.setCreateUser(KefuContext.getKefuContext().getUserId());
        info.setCreateTime(KefuContext.getKefuContext().getNow());
        return info;
    }
}
